package chap04.r21421.d1110;
public  class Demo01 {
    public static void main(String[] args) {
        show(new Student());
    }

    public static  void show(Person person){
        if (person instanceof Teacher){
            Teacher t=(Teacher) person;
            t.teach();
            t.say();
        }else if (person instanceof  Student){
            Student t=(Student) person;
            t.say();
            t.playGame();
        }
    }
}
class Person{
    public   String name="父类";
    public void say(){
        System.out.println("父类的say方法");
    }
}
class Student extends  Person {
    String  name="学生";

    @Override
    public void say(){
        System.out.println("学生回答问题");
    }
    public void playGame(){
        System.out.println("玩游戏");
    }
}

class Teacher extends  Person{

    String  name="老师";

    @Override
    public void say(){
        System.out.println("提问问题");
    }
    public void teach(){
        System.out.println("老师教课");
    }
}
/*

public class Demo01 {
    public static void main(String[] args) {




        //Person p=new Person();
        */
/*多态的弊端  子类不能调用自己特有的方法*//*

      */
/* Student stu=(Student)p;//对象  也是可以进行数据类型转换  只能转换成本类型
       stu.playGame();*//*

       //解决  数据类型转换
       */
/* Teacher t=(Teacher)p;
        t.teach();
        double x=20.5;
        int y=10;
        int sum=(int)(x+y);
        System.out.println(sum);


        System.out.println(p.name);//编译和运行都看左边
        p.say();
        Person p2=new Teacher();
        System.out.println(p2.name);//父类
        p2.say();//提问问题*//*

        */
/*p.say();
        Person p2=new Person();
        p2.say();*//*

    }
}
class Person{
    String name="父类";
    public  void say(){
        System.out.println("父类的say方法");


    */
/*final int AGE=20;// final 修饰不允许重新赋值
    final Student STU=new Student("张三");

    final int[] ARR=new int[]{1,2,3,4,5};
    public void say(){
        //arr=new int[]{2,3,4,5,5,6,7,8};
        ARR[0]=10;
        ARR[1]=20;
       // stu=new Student("李四");
        STU.setName("李四");
    //age=30;
        System.out.println(AGE);*//*

        */
/*System.out.println('a');//char类型的常量
        System.out.println(100);// int  常量  没有byte  short
        System.out.println(20.3);//double 常量
        System.out.println(0x11);//十六进制的17
        System.out.println(011);//八进制的9
        System.out.println(0b11);//二进制的3*//*

    }
}
class Student extends chap04.r21421.d1110.Person {
    private String name;

    public Student(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
//

    @Override
    public void say() {
        System.out.println("回答问题");
    }
        public void playGame(){
            System.out.println("玩游戏");
        }
}

class Teacher extends chap04.r21421.d1110.Person {
    String name="教师";
    @Override
    public void say(){
        System.out.println("提问问题");
    }
    public void teach(){
        System.out.println("教师在讲课");
   }
}
*/
